from tkinter import *

class WidgetsDemo:
	def __init__(self):
		window = Tk()
		window.title("JamesZhang")

		frame1 = Frame(window)
		frame1.pack()
		self.v1 = IntVar()
		cbtBold = Checkbutton(frame1, text = "Bold", variable = self.v1, command = self.processCHECKBUTTON)
		self.v2 = IntVar()
		btRed  = Radiobutton(frame1, text = "red", bg = "red", variable = self.v2,value = 1, command = self.processRadiobutton)
		btYellow = Radiobutton(frame1, text = "Yellow", fg = "Yellow", variable = self.v2,value = 2, command = self.processRadiobutton)
		cbtBold.grid(row = 1,column = 1)
		btRed.grid(row = 1,column = 2)
		btYellow.grid(row = 1,column = 3)

		frame2 = Frame(window)
		frame2.pack()
		label = Label(frame2,text = "Enter your name:",)
		self.name = StringVar()
		entry = Entry(frame2,textvariable = self.name)
		button = Button(frame2,text = "Get Name",command = self.processButton)
		message = Message(frame2,text = "It is a widgets demo")
		label.grid(row = 1,column = 1)
		entry.grid(row = 1,column = 2)
		button.grid(row = 1,column = 3)
		message.grid(row = 1,column = 4)


		text = Text(window)
		text.pack()
		text.insert(END,"Tip\nThe best way to learn Tkinker is to read ")
		text.insert(END,
					"\nBelong to JamesZhang")




		window.mainloop()

	def processCHECKBUTTON(self):
		print("check button is"+("check "if self.v1.get() == 1 else "unchecked"))

	def processRadiobutton(self):
		print(("Red" if self.v2.get() == 1 else "Yellow") + " is selected ")

	def processButton(self):
		print("Your name is ",self.name.get())


WidgetsDemo()